<template>
	<div id="app">
		<router-view></router-view>
		<!-- //定位 -->
		<baidu-map v-if="isMapShow" class="map" @ready="handler" style="height: 0;width: 0;opacity: 0;">
			<bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation>
		</baidu-map>
	</div>
</template>
<script>
	export default {
		name: 'app',
		data() { //数据
			return {
				isMapShow:false,
			}	
		},
		created(){
			this.isMapShow = !this.$store.state.common.cityinfo;
			var value = this.$publicMethod.getPageAllString().value;
			var jsEncrypt = new JSEncrypt();
			var key = "MIICXAIBAAKBgQDCynTRsFYGFKmcwl0PxJ0VtjCENEC43vVIwqBAvrCghHXubK6SJaEk2Qf4r+3uF8QkkerJ4FzVYuRUCDGG2Y9sR5t3epAubspBJPNMO6CNalofryUrf1cqE2uFQfVMAry1bLz9+IIGizzCUhY+x5c2AaZXDiFBk+dQBimtvJksBwIDAQABAoGAB+4OC2tOVTkKHqOa/kVWz8d2+irWZ7BL9AZYV8prjl1WH7q08KYvhTyAopMm8IZvKb32/PjxTo6UFQewXHkG6aNHSdVbVg/wkbnQrWUmnDHkFKFzwRY0sqMoNycMGI1J1T4hSUSkeK53N+KXS1QFkLtpZvgoAZvuxfTYWsUgvQECQQD4lOhoB0QCKZYovUpsddSxWYzDqBti9F6jR3LAPFM9afp5NIowDpEDgwW9Q47eASTeBUAoXPckbT0eYQJipO+hAkEAyJqaJBPo9WUEkUgfL+LSAYP6ZqdsCWh4jKcc8LcXV7WCiPm7wP3jBHkIBJcDQ7IDOnP0lszy7t1Mg2NhhJqapwJARzuEjarnVidMnEgB96qcVGXw7HBTyLt2Exv6ShP/Vm30FJ91qefCrlrxXhbp7bwuMGEYzXg2af3Tsczivhm9gQJBAIPbAvg10gkCZjcsRbuPBmSSoFM7NssUTTB+Y4phfklbeDqak+uttbtp5nhF3pJvfqm8MAezHPcepL0z5JRpnr8CQDx15JE9HXFEa7FohU8sK3jjN9lVMWmU2PafsTWr2kKSIcp19UcMmlFdkUPWaqrQX14GTxrep6URIZJNHeqbLD0=";
			jsEncrypt.setPrivateKey(key);
			var message = decodeURIComponent(value);
			var res = jsEncrypt.decrypt(message);
			// alert(JSON.stringify(this.$publicMethod.getPageAllString()));
			// this.getLotNumber(res);
		},
		mounted(){},
		methods:{
			handler({
				BMap,
				map
			}) {
				let that = this;
				var geolocation = new BMap.Geolocation();
				geolocation.getCurrentPosition(function(r) {
					if(this.getStatus() == BMAP_STATUS_SUCCESS) {
						var mk = new BMap.Marker(r.point);
						map.addOverlay(mk);
						map.panTo(r.point);
						if(r.address.city) {
							var cityinfo = {
								cityName: r.address.city.replace(/市/, ''),
								longitude: r.longitude,
								latitude: r.latitude,
							};
							that.$store.commit('CITYINFO', cityinfo);
						} else {
							var cityinfo = {
								"cityName": "北京",
								"longitude": "116.3971023134",
								"latitude": "39.9129988103"
							};
							that.$store.commit('CITYINFO', cityinfo);
						};
					} else {
						var cityinfo = {
							"cityName": "北京",
							"longitude": "116.3971023134",
							"latitude": "39.9129988103"
						};
						that.$store.commit('CITYINFO', cityinfo);
					}
				}, {
					enableHighAccuracy: true
				})
			},
			getLotNumber(phone){
				if(!phone) return;
				this.$http.post(this.$baseUrl.baseurl + "coupon/app/coupon/newUserCoupon", {}).then((res) => {
					this.login(phone,res.data.Result.lotNumber);
				}).catch((err) => {
					console.log(err);
				});
			},
			login(phone,lotNumber){
				var param = {
					phone: phone,
					channels: "4",
					InvitationOthers: "",
					lotNumber: lotNumber || 1,
					activityH5: "activityH5",
					// wxApplet: "trainWxApplet",
				};
				this.$http.post(this.$baseUrl.baseurl + "kpcx/dynamicLoginForApp", param).then((res) => {
					if (res.data.Code == "0") {
						var userInfo = res.data.Result.appuser;
						if(userInfo) {
							userInfo.realnamestatus = Boolean(userInfo.IDNo);
							this.$store.commit('USERINFO', userInfo);
						} else {
							this.$toast('用户信息不存在');
						};
					} else {
						this.$toast(res.data.msg);
					};
				}).catch((err) => {
					console.log(err);
				});
			}
		}
	}
</script>

<style>
	body,
	h1,
	h2,
	h3,
	h4,
	h5,
	h6,
	hr,
	p,
	blockquote,
	dl,
	dt,
	dd,
	ul,
	ol,
	li,
	pre,
	form,
	fieldset,
	legend,
	button,
	input,
	textarea,
	th,
	td {
		margin: 0;
		padding: 0;
		font-family: "MicrosoftYaHei";
	}
	
	body,
	button,
	input,
	select,
	textarea {
		font-family: "微软雅黑";
		letter-spacing: 0.02rem;
		line-height: 1;
	}
	
	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		font-size: 100%;
	}
	
	address,
	cite,
	dfn,
	em,
	var {
		font-style: normal;
	}
	
	code,
	kbd,
	pre,
	samp {
		font-family: couriernew, courier, monospace;
	}
	
	small {
		font-size: 12px;
	}
	
	ul,
	ol {
		list-style: none;
	}
	
	a {
		text-decoration: none;
	}
	
	a:hover {
		text-decoration: none;
	}
	
	sup {
		vertical-align: text-top;
	}
	
	sub {
		vertical-align: text-bottom;
	}
	
	legend {
		color: #000;
	}
	
	fieldset,
	img {
		border: 0;
	}
	
	button,
	input,
	select,
	textarea {
		font-size: 100%;
	}
	
	table {
		border-collapse: collapse;
		border-spacing: 0;
	}
	
	input[type=button],
	input[type=submit],
	input[type=file],
	button {
		cursor: pointer;
		-webkit-appearance: none;
	}
	/*//清浮动*/
	
	Element {
		-webkit-user-select: none;
		-moz-user-select: none;
		-khtml-user-select: none;
		user-select: none;
	}
	*{
		-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
		-webkit-tap-highlight-color:transparent;
	}
	.fl {
		float: left;
	}
	
	.fr {
		float: right;
	}
	
	.wccy-after:after {
		content: "";
		display: block;
		overflow: hidden;
		clear: both;
	}
	
	.kp-banner .swiper-container-horizontal>.swiper-pagination-bullets>.swiper-pagination-bullet {
		width: 12px;
		height: 12px;
		background: #fff;
		opacity: 1;
	}
	
	.kp-banner .swiper-container-horizontal>.swiper-pagination-bullets>.swiper-pagination-bullet-active {
		background: #69b452;
		width: 43px;
		height: 12px;
		border-radius: 6px;
	}
	/* margin */
	
	.mt-30 {
		margin-top: 30px !important;
	}
	
	.mt-20 {
		margin-top: 20px !important;
	}
	
	.mtb-20 {
		margin: 20px 0 !important;
	}
	
	.mb-18 {
		margin-bottom: 18px !important;
	}
	/* padding */
	
	.plr-30 {
		padding: 0 30px;
	}
	/*hx*/
	
	.hx-20 {
		height: 20px;
		background: rgba(248, 248, 248, 1);
	}
	
	.mar_bot {
		margin-bottom: 30px;
	}
	
	.right {
		text-align: right;
	}
	
	#app {
		width: 750px;
		margin: 0 auto;
	}
	
	html {
		background: #F4F5F9;
	}
	
	body {
		background: #fdfdfd;
	}
	
	.kp-flex-1 {
		flex: 1;
	}
	/* 箭头 */
	
	.kp-icon-1 {
		background: url(assets/right-1.png) no-repeat right center;
		background-size: 14px 25px;
	}
	/*//公共字体*/
	
	.fm-pfb {
		font-family: "PingFang SC Bold";
	}
	
	.fm-pfm {
		font-family: "PingFang SC Medium";
	}
	
	::-webkit-scrollbar {
		width: 1px;
		height: 1px;
		background-color: #F5F5F5;
	}
	
	.tl {
		text-align: left;
	}
	
	.tr {
		text-align: right;
	}
	
	.tc {
		text-align: center;
	}
	/*定义滚动条轨道 内阴影+圆角*/
	
	::-webkit-scrollbar-track {
		-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
		border-radius: 10px;
		background-color: #F5F5F5;
	}
	/*定义滑块 内阴影+圆角*/
	
	::-webkit-scrollbar-thumb {
		border-radius: 10px;
		-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
		background-color: #555;
	}
	/*文字超出省略号*/
	
	.font_spill {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		padding-top: 4px;
	}
	
	.train {
		/*touch-action: none;*/
	}
	
	.train img {
		pointer-events: none;
		vertical-align: sub;
	}
	
	/*.train div,p,header,span {
		touch-action: none;
	}*/
	
	.fade-enter-active,
	.fade-leave-active {
		transition: opacity .5s
	}
	
	.fade-enter,
	.fade-leave-active {
		opacity: 0
	}
	/* //提示语句样式 */
	
	.vux-toast .weui-toast.vux-toast-top {
		top: 10%;
	}
	.vux-toast .weui-toast.vux-toast-top .weui-toast__content {
		font-size: 30px;
		padding: 20px 30px !important;
	}
	.kp-cts-li p{
		font-size:26px;
		font-family:PingFangSC-Light;
		color:rgba(134,134,134,1);
		line-height: 1.5;
		word-break: break-all;
		margin-bottom: 20px;
	}
</style>